Skip to content

Adds metrics and log fields for tracking TLS handshake bytes#12763

Open
zwoop wants to merge 4 commits intoapache:masterfrom
zwoop:HandshakeMetrics
Open

Adds metrics and log fields for tracking TLS handshake bytes#12763
zwoop wants to merge 4 commits intoapache:masterfrom
zwoop:HandshakeMetrics

Conversation

@zwoop
Copy link
Contributor

@zwoop zwoop commented Dec 16, 2025

No description provided.

@zwoop zwoop added this to the 10.2.0 milestone Dec 16, 2025
@zwoop zwoop requested a review from moonchen December 16, 2025 18:23
@zwoop zwoop self-assigned this Dec 16, 2025
@zwoop zwoop force-pushed the HandshakeMetrics branch 4 times, most recently from 3bfc675 to 9300fc0 Compare December 16, 2025 18:32
@zwoop zwoop force-pushed the HandshakeMetrics branch 2 times, most recently from f43460e to da26361 Compare December 16, 2025 22:56
@zwoop
Copy link
Contributor Author

zwoop commented Dec 16, 2025

I think I've addressed @maskit's concerns in the latest update.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds visibility into the network cost of TLS handshakes by exposing handshake byte counts as both process metrics and new logging fields. It integrates the measurement at the TLS layer (BIO byte counters) and surfaces it through HttpUserAgent/LogAccess, with documentation updates for the new log format tokens.

Changes:

  • Add TLS handshake byte capture to TLSBasicSupport and increment new process counters on SSL_CB_HANDSHAKE_DONE.
  • Introduce new logging fields for handshake bytes (rx/tx/total) and “squid length + handshake bytes” variants for first transactions.
  • Document the new log format symbols in the admin guide.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/proxy/logging/LogAccess.cc Adds marshalers for new TLS-handshake-related log fields and squid-len+TLS variants.
src/proxy/logging/Log.cc Registers new log fields and short symbols (cqqtl, cthbr, cthbt, cthb, psqtl).
src/iocore/net/TLSBasicSupport.cc Implements handshake byte retrieval/caching via BIO counters.
src/iocore/net/SSLUtils.cc Increments new handshake-byte metrics when the handshake completes.
src/iocore/net/SSLStats.h / src/iocore/net/SSLStats.cc Adds and initializes new counters for total handshake bytes in/out.
include/proxy/logging/LogAccess.h Declares new LogAccess marshalers.
include/proxy/http/HttpUserAgent.h Stores TLS handshake rx/tx bytes and early-data length into ClientConnectionInfo.
include/iocore/net/TLSBasicSupport.h Declares get_tls_handshake_bytes().
src/iocore/net/SSLNetVConnection.cc Minor formatting adjustment in clear().
doc/admin-guide/logging/formatting.en.rst Documents new log symbols and descriptions.

- Use _tls_handshake_bytes_measured flag instead of > 0 sentinel,
  so the cache works correctly when both byte counts are zero
- Use std::min() when subtracting early data from handshake_rx to
  handle the == case and prevent underflow
- Add static_cast<int64_t> to marshal_int calls for rx/tx bytes
@zwoop zwoop requested a review from bneradt February 26, 2026 23:53
@zwoop zwoop dismissed bneradt’s stale review February 26, 2026 23:54

Addressed all concerns.

@zwoop
Copy link
Contributor Author

zwoop commented Feb 27, 2026

[approve ci centos]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants